Skip to content

[Feature] support blackwell gemm in ht#7053

Merged
heavengate merged 6 commits into
PaddlePaddle:developfrom
lizhenyun01:black_gemm
Apr 7, 2026
Merged

[Feature] support blackwell gemm in ht#7053
heavengate merged 6 commits into
PaddlePaddle:developfrom
lizhenyun01:black_gemm

Conversation

@lizhenyun01
Copy link
Copy Markdown
Collaborator

@lizhenyun01 lizhenyun01 commented Mar 27, 2026

Motivation

支持高吞吐模式下高性能moe gemm backend,使用需配合算子仓库 使用方式:
export FD_USE_BLACKWELL_GEMM=1
当前需与deepgemm同时开启

Modifications

Usage or Command

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Mar 27, 2026

Thanks for your contribution!

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 1.72414% with 285 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@4425142). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...executor/layers/moe/fused_moe_blackwell_backend.py 0.00% 274 Missing ⚠️
...el_executor/layers/moe/fused_moe_triton_backend.py 30.00% 6 Missing and 1 partial ⚠️
...del_executor/layers/quantization/block_wise_fp8.py 33.33% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7053   +/-   ##
==========================================
  Coverage           ?   73.30%           
==========================================
  Files              ?      377           
  Lines              ?    53138           
  Branches           ?     8286           
==========================================
  Hits               ?    38954           
  Misses             ?    11475           
  Partials           ?     2709           
Flag Coverage Δ
GPU 73.30% <1.72%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread fastdeploy/model_executor/layers/quantization/fp8_utils.py
Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Code Review | 2026-04-02 19:56 CST

📋 Review 摘要

PR 概述:支持高吞吐模式下 Blackwell 架构的高性能 MoE GEMM 后端
变更范围model_executor/layers/moe/model_executor/layers/quantization/envs.py
影响面 TagOP Quantization

📝 PR 规范检查

PR 标题和描述基本符合规范。建议补充 Modifications 部分的具体变更说明。

描述补充建议(可直接复制):

## Modifications

1. 新增环境变量 `FD_USE_BLACKWELL_GEMM` 控制 Blackwell GEMM 后端开关
2. 新增 `fused_moe_blackwell_backend.py` 实现 Blackwell 架构的 MoE 计算
3. 修改 `block_wise_fp8.py` 添加 Blackwell 量化方法分支
4. 修改 `fused_moe_triton_backend.py` 支持 Blackwell scale 格式转换

问题

级别 文件 概述
🟡 建议 envs.py:79 注释复制粘贴错误
🟡 建议 fused_moe_blackwell_backend.py:280 类 docstring 描述错误
🟡 建议 fused_moe_blackwell_backend.py:482 重复的解包操作
❓ 疑问 fused_moe_triton_backend.py:1716 scale 设为 None 可能影响其他代码路径

总体评价

代码实现整体结构清晰,继承了 DeepGemm 后端的设计模式。主要问题是一些复制粘贴导致的注释/文档错误和冗余代码,建议修复后合入。

Comment thread fastdeploy/envs.py
"FD_PD_CHANGEABLE": lambda: os.getenv("FD_PD_CHANGEABLE", "0"),
# Whether to use DeepGemm for FP8 blockwise MoE.
"FD_USE_DEEP_GEMM": lambda: bool(int(os.getenv("FD_USE_DEEP_GEMM", "0"))),
# Whether to use DeepGemm for FP8 blockwise MoE.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 注释复制粘贴错误

当前注释 # Whether to use DeepGemm for FP8 blockwise MoE. 与上一行 FD_USE_DEEP_GEMM 的注释完全相同,应该描述 Blackwell GEMM 的用途。

建议修改为:

# Whether to use Blackwell GEMM for FP8 blockwise MoE (SM100+).
"FD_USE_BLACKWELL_GEMM": lambda: bool(int(os.getenv("FD_USE_BLACKWELL_GEMM", "0"))),



class BlackwellGemmFusedMoeMethod(MoEMethodBase):
"""
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 类 docstring 描述错误

当前 docstring 描述的是 DeepGemmFusedMoeMethod,但实际类名是 BlackwellGemmFusedMoeMethod

建议修改为:

class BlackwellGemmFusedMoeMethod(MoEMethodBase):
    """
    BlackwellGemmFusedMoeMethod is a class that implements the MoEMethodBase interface for Blackwell GEMM backend.
    """

global_values[thread_name] = {}

(recv_x_value, recv_x_scale) = recv_x
(recv_x_value, recv_x_scale) = recv_x
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 重复的解包操作

(recv_x_value, recv_x_scale) = recv_x 被连续执行了两次(第481行和第482行),是明显的冗余代码。

建议删除重复行:

(recv_x_value, recv_x_scale) = recv_x
# 删除下面这行重复的解包

Comment thread fastdeploy/model_executor/layers/moe/fused_moe_triton_backend.py
Copy link
Copy Markdown
Collaborator

@qingqing01 qingqing01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后续需要规范此包的使用方式及环境变量、增加单测

@lizhenyun01
Copy link
Copy Markdown
Collaborator Author

后续需要规范此包的使用方式及环境变量、增加单测

好的 算子包发布时会增加使用规范及监控

@heavengate heavengate merged commit 446b26b into PaddlePaddle:develop Apr 7, 2026
33 of 38 checks passed
xiaoguoguo626807 pushed a commit to xiaoguoguo626807/FastDeploy that referenced this pull request May 7, 2026
* [Feature] support blackwell gemm in ht

* [Feature] support ops for convert

* fix cuda error 716

* fix cuda error

* opt memory

* remove unused code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants